Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize placeholder based on first language #201

Merged
merged 6 commits into from
Mar 18, 2019

Conversation

scottsfarley93
Copy link

Implements the change suggested in #150 by localizing the placeholder value based on the provided language option set in the constructor.

@scottsfarley93 scottsfarley93 changed the base branch from master to version4 March 13, 2019 21:33
@scottsfarley93 scottsfarley93 added this to the v4.0.0 milestone Mar 13, 2019
lib/index.js Outdated
* Otherwise, if language is provided in options, then use the localized string of the first language if available
* Otherwise use the default
*/
getPlaceholderText: function(){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this method be private?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to https://github.com/mapbox/mapbox-gl-geocoder/pull/198/files#r265396617 but I think it's better to re-gen the docs with each commit and include them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Moved this to be a private method.

var localizedValue = localization.placeholder[language];
if (localizedValue) return localizedValue;
}
return 'Search';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also lookup 'en' in localization.placeholder, but I don't think it really matters.

*
* If placeholder is provided in options, then use options.placeholder
* Otherwise, if language is provided in options, then use the localized string of the first language if available
* Otherwise use the default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a JSDoc @returns here for completeness.

Copy link
Contributor

@katydecorah katydecorah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants